﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ((TitledPage)Master).Title = "Login";



        string returnUrl = Request.QueryString["ReturnUrl"];


        //没有returnUrl，用户自己输入地址到达这里的。
        if (string.IsNullOrEmpty(returnUrl))
            return;


        var res = UrlAuthorizationModule.CheckUrlAccessForPrincipal(returnUrl, User, "get");

        if (res)//用户是可以访问returnUrl指定的页面的，说明用户是在那个页面上点击登录链接而来的，不用显示消息。
        { }
        else
        {
            accessFailMessageLabel.Text = string.Format("You are not allowed to visit {0}. {1} or go back.",
                System.IO.Path.GetFileName(returnUrl), User.Identity.IsAuthenticated ? "Switch to another account" : "Login");
        }
    }
}